/**
 * ipassbook 0.6.0
 * Copyright (C)2009 wateray and contributors
 * wateray@gmail.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

package com.wateray.ipassbook.persistence.sqlmapdao;

import java.util.List;

import com.ibatis.dao.client.DaoManager;
import com.wateray.ipassbook.domain.Subject;
import com.wateray.ipassbook.persistence.iface.SubjectDao;

public class SubjectSqlMapDao extends BaseSqlMapDao implements SubjectDao {

	public SubjectSqlMapDao(DaoManager daoManager) {
		super(daoManager);
		// TODO Auto-generated constructor stub
	}

	@Override
	public Subject getSubjectBySubjectId(String subjectId) {
		 return (Subject) queryForObject("getSubjectBySubjectId", subjectId);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Subject> getSubjectListBySubjectFlag(String subjectFlag) {
		 return queryForList("getSubjectListBySubjectFlag", subjectFlag);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<Subject> getSubjectListByParentId(String parentId) {
		 return queryForList("getSubjectListByParentId", parentId);
	}
	
	@Override
	public int insertSubject(Subject subject) {
		return update("insertSubject", subject);
	}

	@Override
	public int updateSubject(Subject subject) {
		// TODO Auto-generated method stub
		return update("updateSubject", subject);
	}
	
	@Override
	public int deleteSubject(Subject subject) {
		// TODO Auto-generated method stub
		return update("deleteSubject", subject);
	}

	@Override
	public String getMaxId() {
		// TODO Auto-generated method stub
		return (String)queryForObject("getMaxId");
	}

	@Override
	public int getMaxOrderOfFlag(String flag) {
		// TODO Auto-generated method stub
		return ((Integer)queryForObject("getMaxOrderOfFlag", flag)).intValue();
	}

	@Override
	public int getMaxOrderOfParent(String parentId) {
		// TODO Auto-generated method stub
		return ((Integer)queryForObject("getMaxOrderOfParent", parentId)).intValue();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Subject> getAllSubjectList() {
		// TODO Auto-generated method stub
		 return queryForList("getAllSubjectList");
	}

}
